/**
 * 
 */
package com.taobao.client;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.CellPanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * with some style
 * 
 * @author 
 * 
 */
public class HeadPanel extends Composite {
	private CellPanel content;

	public HeadPanel() {
		this(false);
	}
	
	/**
	 * 原型:<br>
	 * <div class="toolbg msg_info"
	 * style="height: auto; background-image: none;"> <div class="left"></div>
	 * <div class="right"></div> <div class="content"
	 * style="padding: 0pt 8px 4px 12px;"> 1.已经售出商品页面</div> <div class="clear">
	 * <div class="left bottom_l"></div> <div class="right bottom_r"></div>
	 * </div> </div>
	 */
	public HeadPanel(boolean horizontal) {
		VerticalPanel init = new VerticalPanel();

		initcontent(horizontal);

		init.setWidth("100%");
		// Set the background color
		init.addStyleName("toolbg");
		init.addStyleName("msg_info");

		AbsolutePanel t = new AbsolutePanel();

		AbsolutePanel l = new AbsolutePanel();
		l.addStyleName("left");

		AbsolutePanel r = new AbsolutePanel();
		r.addStyleName("right");

		content.addStyleName("content");

		AbsolutePanel clear = new AbsolutePanel();
		clear.addStyleName("clear");

		AbsolutePanel bg = new AbsolutePanel();
		bg.addStyleName("left");
		bg.addStyleName("bottom_l");

		AbsolutePanel bg_r = new AbsolutePanel();
		bg_r.addStyleName("right");
		bg_r.addStyleName("bottom_r");

		t.add(l);
		t.add(r);

		clear.add(bg);
		clear.add(bg_r);

		init.add(t);
		init.add(content);
		init.add(clear);

		initWidget(init);
	}

	public void initcontent(boolean horizontal) {
		if (!horizontal) {
			content = new VerticalPanel();
			((VerticalPanel) content)
					.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
		} else {
			content = new HorizontalPanel();
			((HorizontalPanel) content)
					.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
		}
	}

	public void add(Widget w) {
		content.add(w);
	}
}
